/**
 * This class's only function is to map tiles from the texture map to their respective materials. 
 */

package org.bukkitmodders.copycat.util;

import java.util.HashSet;

import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Block;

public class MaterialTiles {

	private static int COBBLESTONE = 16;
	private static int WOOL_WHITE = 64;

	private static int WOOL_BLACK = 113;
	private static int WOOL_GRAY = 114;

	private static int WOOL_RED = 129;
	private static int WOOL_PINK = 130;

	private static int WOOL_GREEN = 145;
	private static int WOOL_LIGHT_GREEN = 146;

	private static int WOOL_BROWN = 161;
	private static int WOOL_YELLOW = 162;

	private static int WOOL_BLUE = 177;
	private static int WOOL_LIGHT_BLUE = 178;

	private static int WOOL_PURPLE = 193;
	private static int WOOL_LIGHT_PURPLE = 194;

	private static int WOOL_CYAN = 209;
	private static int WOOL_ORANGE = 210;

	private static int WOOL_LIGHT_GRAY = 225;

	private static HashSet<Integer> SUPPORTED_TILES;

	static {
		HashSet<Integer> supportedTiles = new HashSet<Integer>();
		supportedTiles.add(WOOL_WHITE);
		supportedTiles.add(WOOL_BLACK);
		supportedTiles.add(WOOL_GRAY);
		supportedTiles.add(WOOL_RED);
		supportedTiles.add(WOOL_PINK);
		supportedTiles.add(WOOL_GREEN);
		supportedTiles.add(WOOL_LIGHT_GREEN);
		supportedTiles.add(WOOL_BROWN);
		supportedTiles.add(WOOL_YELLOW);
		supportedTiles.add(WOOL_BLUE);
		supportedTiles.add(WOOL_LIGHT_BLUE);
		supportedTiles.add(WOOL_PURPLE);
		supportedTiles.add(WOOL_LIGHT_PURPLE);
		supportedTiles.add(WOOL_CYAN);
		supportedTiles.add(WOOL_ORANGE);
		supportedTiles.add(WOOL_LIGHT_GRAY);
		// supportedTiles.add(COBBLESTONE);

		SUPPORTED_TILES = supportedTiles;
	}

	public static HashSet<Integer> getSupportedTiles() {
		return SUPPORTED_TILES;
	}

	public static void setBlockMaterialToTile(int tile, Block block) {

		if (tile == COBBLESTONE) {
			block.setType(Material.COBBLESTONE);
		} else if (tile == WOOL_WHITE) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.WHITE.getData());
		} else if (tile == WOOL_BLACK) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.BLACK.getData());
		} else if (tile == WOOL_GRAY) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.GRAY.getData());
		} else if (tile == WOOL_RED) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.RED.getData());
		} else if (tile == WOOL_PINK) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.PINK.getData());
		} else if (tile == WOOL_GREEN) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.GREEN.getData());
		} else if (tile == WOOL_LIGHT_GREEN) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.LIME.getData());
		} else if (tile == WOOL_BROWN) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.BROWN.getData());
		} else if (tile == WOOL_YELLOW) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.YELLOW.getData());
		} else if (tile == WOOL_BLUE) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.BLUE.getData());
		} else if (tile == WOOL_LIGHT_BLUE) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.LIGHT_BLUE.getData());
		} else if (tile == WOOL_PURPLE) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.PURPLE.getData());
		} else if (tile == WOOL_LIGHT_PURPLE) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.MAGENTA.getData());
		} else if (tile == WOOL_CYAN) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.CYAN.getData());
		} else if (tile == WOOL_ORANGE) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.ORANGE.getData());
		} else if (tile == WOOL_LIGHT_GRAY) {
			block.setType(Material.WOOL);
			block.setData(DyeColor.SILVER.getData());
		} else {
			throw new RuntimeException("Unsupported Tile Number: " + tile);
		}
	}
}
